import axios from '@/utils/request'
import { IPageResult } from './types/base'
import {
  IEntityChangeDetail,
  IEntityChangeLog,
  IEntityChangeParams,
} from './types/entityChangeLog'

// 获取某一次实体变更记录
export function getEntityChange(entityChangeId: string) {
  return axios<IEntityChangeDetail>({
    url: '/api/common/audit-log/entity-change',
    method: 'get',
    params: {
      entityChangeId,
    },
  })
}

// 获取实体变更记录
export function getEntityChangeLog(
  currentPage = 1,
  take = 10,
  params: IEntityChangeParams,
) {
  return axios<IPageResult<IEntityChangeLog>>({
    url: '/api/common/audit-log/entity-change-list',
    method: 'get',
    params: Object.assign(
      {
        skipCount: take * (currentPage - 1),
        maxResultCount: take,
      },
      params,
    ),
  })
}
